/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *	  http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.milib.dbg.model.content {
	import com.googlecode.milib.base.MLBroadcastClass;

	/**
	 * @author Marek Brun
	 */
	public class MLDBGTextModel extends MLBroadcastClass {
		
		public const event_TextChanged : String = 'TextChanged';
		
		//DATA:	String //added text		public const event_AddText : String = 'AddText';
		
		protected var text:String='';
		private var texts:Array=[];
		
		public function MLDBGTextModel() {
			
		}
		
		public function setText(text:String):void {
			this.text=text;
			broadcastEvent(event_TextChanged);
		}
		
		public function addText(text:String):void {
			this.text+=text;
			texts.push(text);
			if(texts.length>100){
				while(texts.length>90){
					texts.shift();
				}
			}
			broadcastEvent(event_AddText, text);
			broadcastEvent(event_TextChanged);
		}
		
		public function getText():String {
			return texts.join('');
		}
	}
}
